import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OperatorQuery, OperatorVO, addOrEditForm } from './types';
import { MerchantAccountCreateXnForm, MerchantAccountListFpForm } from '@/api/enterprise/addEnterprise/types';

/**
 * 查询运营商列表
 * @param query
 */
export const operatorList = (query: OperatorQuery): AxiosPromise<OperatorVO[]> => {
  return request({
    url: '/payment/operator/list',
    method: 'get',
    params: query
  });
};


/**
 * 添加or修改运营商
 */
export const addOrEditOperator = (data: addOrEditForm, method: string = 'post') => {
  return request({
    url: '/payment/operator',
    method,
    data,
  });
};

/**
 * 运营商详情
*/
export const operatorDetail = (id: string | number) => {
  return request({
    url: `/payment/operator/${id}`,
    method: 'get',
  });
};
/**
 * 虚拟户列表查询
 */
export const operatorAccountListFp = (params: MerchantAccountListFpForm) => {
  return request({
    url: 'payment/operatorAccount/listFp',
    method: 'get',
    params,
  });
};

/**
 * 创建虚拟户
 */
export const operatorAccountCreateXn = (params: MerchantAccountCreateXnForm) => {
  return request({
    url: 'payment/operatorAccount/createXn',
    method: 'post',
    params,
  });
};


export default {
  operatorList,
  operatorDetail,
  addOrEditOperator,
  operatorAccountListFp,
  operatorAccountCreateXn,
};
